/**
 *
 */
package com.ssyt.examinationsystem.service.impl;

import com.ssyt.examinationsystem.dao.ISubjectiveInfoDAO;
import com.ssyt.examinationsystem.dao.impl.SubjectiveInfoDAOImpl;
import com.ssyt.examinationsystem.entity.PageBean;
import com.ssyt.examinationsystem.entity.SubjectiveInfo;
import com.ssyt.examinationsystem.service.ISubjectiveInfoService;

import java.util.List;
import java.util.Map;

/**
 * @author Long.
 * @version 1.0
 * @className SubjectiveInfoServiceImpl
 * @since 2016年10月30日
 */
public class SubjectiveInfoServiceImpl implements ISubjectiveInfoService {

    ISubjectiveInfoDAO subDao = new SubjectiveInfoDAOImpl();

    @Override
    public int addSubjectiveInfo(SubjectiveInfo subjective) {
        return subDao.addSubjectiveInfo(subjective);
    }

    @Override
    public List<Map<String, Object>> getSubjective() {
        return subDao.getSubjective();
    }

    @Override
    public int updateSubjective(SubjectiveInfo subjective) {
        return subDao.updateSubjective(subjective);
    }

    @Override
    public int deleteSubjective(String subId) {
        return subDao.deleteSubjective(subId);
    }

    @Override
    public PageBean getSubjectiveByPage(PageBean page) {
        // 获取分页总记录数
        Integer totalRecords = subDao.getTotalCount();
        // 获取每页显示数
        Integer pageSize = page.getPageSize();
        // 获取当前页
        Integer currentPage = page.getCurrentPage();
        List<Map<String, Object>> subjectiveList = subDao.getSubjectiveByPage(page);
        // 创建一个分页对象
        PageBean pageBean = new PageBean(totalRecords, pageSize, currentPage);
        pageBean.setList(subjectiveList);

        return pageBean;
    }

    /* (non-Javadoc)
     * @see com.ssyt.examinationsystem.service.ISubjectiveInfoService#getSubById(java.lang.String)
     */
    @Override
    public Map<String, Object> getSubById(String subId) {
        return subDao.getSubById(subId);
    }

}
